package org.mockserver.maven;

import org.json.HTTP;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.initialize.ExpectationInitializer;
import org.mockserver.model.HttpForward;
import org.mockserver.model.HttpRequest;

import static org.mockserver.integration.ClientAndServer.startClientAndServer;

/**
 * Created by liuyu21 on 2017/10/16.
 */
public class ExampleInitializationClass implements ExpectationInitializer {


    @Override
    public void initializeExpectations(MockServerClient mockServerClient) {
        System.out.println("mock server , hello world");
        MockServerClient mockServer = startClientAndServer(1081);
        mockServer.when(
                HttpRequest.request()
                        .withPath("/helloworld")
        ).forward(
                HttpForward.forward()
                .withHost("www.mock-server.com")
                .withPort(80)
                .withScheme(HttpForward.Scheme.HTTP)
        );
    }
}
